package k2_oop.p1_classAndObject.demo14;

public class Bike {

    public int speed;

    Car car = new Car(80);

    public Bike(int speed) {
        this.speed = speed;
    }

    /**
     * 做加速，将加速后的速度进行判断是否超速，如果超速，给出提示
     */
    public void speedUp(){
        this.speed+=10;
        if (car.isOverSpeed(this.speed)) {
            System.out.println("已经超速了");
        }
    }

    /**
     * 做减速，将减速后的速度进行判断是否超速，如果超速，给出提示
     */
    public void speedDown(){
        this.speed-=10;
        if (car.isOverSpeed(this.speed)){
            System.out.println("依然超速");
        }
    }

}
